package com.pk.platform.business.common.service.impl;

import com.pk.platform.business.common.dao.IContactDao;
import com.pk.platform.business.common.service.IContactService;
import com.pk.platform.business.common.vo.ContactVO;
import com.pk.platform.domain.common.Contact;
import com.pk.platform.util.constant.Constant;
import com.pk.platform.util.page.ListPage;
import com.pk.platform.util.page.Pager;

public class ContactServiceImpl implements IContactService{

	private IContactDao contactDao;

	public IContactDao getContactDao() {
		return contactDao;
	}

	public void setContactDao(IContactDao contactDao) {
		this.contactDao = contactDao;
	}
	
	public Contact getContactById(String id){
		return contactDao.get(Contact.class, id);
	}
	/* (non-Javadoc)
	 * @see com.pk.platform.business.common.service.impl.ContactService#addContact(com.pk.platform.domain.common.Contact)
	 */
	public String addContact(Contact ct) {
		contactDao.add(ct);
		contactDao.addOperateLog("新增联系方式", Constant.SUCCESSFUL, ct.getKindergarten());
		return Constant.SUCCESS;
	}
	
	/* (non-Javadoc)
	 * @see com.pk.platform.business.common.service.impl.ContactService#delContact(java.lang.String)
	 */
	public String delContact(String id){
		Contact contact = this.getContactById(id);
		contactDao.addOperateLog("删除联系方式", Constant.SUCCESSFUL, contact.getKindergarten());
		contactDao.delete(Contact.class,id);
		return Constant.SUCCESS;
	}
	
	/* (non-Javadoc)
	 * @see com.pk.platform.business.common.service.impl.ContactService#updateContact(com.pk.platform.domain.common.Contact)
	 */
	public String updateContact(Contact ct){
		contactDao.update(ct);
		/*Contact c = contactDao.get(ct.getClass(), ct.getId());
		c.setName(ct.getName());
		c.setPhone(ct.getPhone());
		c.setAddress(ct.getAddress());
		c.setEmail(ct.getEmail());
		c.setType(ct.getType());
		c.setDescription(ct.getDescription());
		c.setUrl(ct.getUrl());*/
		contactDao.addOperateLog("修改联系方式", Constant.SUCCESSFUL, ct.getKindergarten());
		return Constant.SUCCESS;
	}
	
	/* (non-Javadoc)
	 * @see com.pk.platform.business.common.service.impl.ContactService#queryContact(com.pk.platform.business.common.vo.ContactVO, com.pk.platform.util.page.Pager)
	 */
	public ListPage queryContact(ContactVO ctvo, Pager pager) {
		return contactDao.queryContact(ctvo, pager);
	}
}
